package com.nuanshui.heatedloan.web.credit;

import com.alibaba.dubbo.config.annotation.Reference;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.credit.facade.BankCardService;
import com.nuanshui.heatedloan.credit.form.BankCardForm;
import com.nuanshui.heatedloan.credit.vo.BankCardVO;
import com.nuanshui.heatedloan.pageable.Pager;
import com.nuanshui.heatedloan.web.ApiController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zss
 * @date 2017/7/31 19:35
 * @description
 * @Since
 */
@RequestMapping("/cms/manage/bankcard")
@RestController
public class BankCardController extends ApiController {

    @Reference(url= GlobalParam.CREDIT_DUBBO_SERVER,timeout= GlobalParam.DUBBO_SERVER_TIME_OUT,version =GlobalParam.CREDIT_DUBBO_SERVER_VERSION )
    private BankCardService bankCardService;

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public String list(Pager<BankCardVO> pager){
        pager= bankCardService.loadBankCard(pager);
        return success(pager.asHashMap());
    }

    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public String create(BankCardForm bankCardForm){
        boolean flag= bankCardService.saveBankCard(bankCardForm)>0?true:false;
        if(flag){
            return success("新增成功");
        }
        return fail("新增失败");
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public String update(String id, String status){
       if (bankCardService.updateBankCard(id,status)){
           return success("修改成功");
       }
       return fail("修改失败");
    }


}
